<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>3788：ZL密码锁</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">ZL密码锁</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">ZL密码锁</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                ZL密码锁                </h1>
                <p>时间限制：20s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：128MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><div>话说考古学家ZL走进了一个山洞&hellip;&hellip;&hellip;&hellip;</div>
<div>ZL在山洞深处发现了一组密码锁，并断定这里藏着数不清的宝藏。经过一番寻找，ZL发现该密码锁上写着一串阿拉伯数字，看起来这些数字中有着一些微妙的联系。于是他动用了120分脑细胞，凭着藐视一切IMO选手的强大逻辑推理能力，找到了规律，并破解了几个密码锁。</div>
<div>可ZL毕竟是人，他也是会累的呀T_T</div>
<div>况且他的GPS显示前方还有成百上千个密码锁~！！！！</div>
<div>于是他把问题简化了一下，求助于身为OI神犇的你。</div>
<div>{============================================}</div>
<div>数列a[n]由如下关系式定义：</div>
<div>a[0]=0;</div>
<div>a[n]=f(a[n-1])</div>
<div>其中f(x)是一个正整数系数的m次多项式</div>
<div>对任意给定的x和y，求a[x]和a[y]的最大公约数d</div>
<div>令s为d模x的余数，t为d模y的余数</div>
<div>给定r和一个奇质数p，保证r不是p的整数倍</div>
<div>废话完毕，现在我们的问题是：</div>
<div>求方程 (rx2+sx+t) mod p = 0</div>
<div>有几个模p意义下的正整数解</div>
<div>对每个函数y=f(x)将进行T次询问</div>
<p></p></p><hr/><h3>输入格式</h3><p><div>输入文件包括T+3行</div>
<div>第一行一个正整数m</div>
<div>第二行m+1个正整数cm，&hellip;，c0，其中ci(i=m，m-1，&hellip;，0)表示f(x)中xi的系数</div>
<div>第三行一个正整数T，表示询问次数</div>
<div>以下T行每行4个正整数，分别表示x，y，r，p</div>
<div>//保证输入文件合法</div>
<p></p></p><hr/><h3>输出格式</h3><p><div>
<div>输出文件包含T行，每行仅输出一个整数表示方程有多少组解（模p的意义下）</div>
</div>
<div>
<p></p>
</div></p><hr/><h3>样例输入</h3><pre>1
2 1
1
4 8 7 3</pre><hr/><h3>样例输出</h3><pre>0
</pre><hr/><h3>提示</h3><p><p><a id="fck_paste_padding">﻿</a>对于100%的数据，T&lt;=1000，m&lt;=10，x&lt;y，x&lt;=10^5，y&lt;=10^8，p&lt;=10^8。</p>
<div></div>
<p></p></p><hr/><h3>题目来源</h3><p>没有写明来源</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=3788" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=3788" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>